home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
mxutil
/
tspak17
/
tspak.doc
< prev
Wrap
Text File
|
1994-09-11
|
61KB
|
1,291 lines
Tandy DAC Sound Package
Version 1.7
September 11, 1994
Send comments, bug reports to:
Jeffrey L. Hayes
130 Forest Ave., Lot 1
Orono, Me. 04473
(207) 866-7903
Internet: tvdog@delphi.com
Contents
--------
1. Introduction
2. Playwav
3. Recwav
4. Ppwav
5. Raw2wav
6. Snd2sam
7. Setdac
8. Piano
9. Work in Progress
Introduction
------------
As noted in the file Tandac.doc (included in this package),
there is a general lack of software support for the built-in
digital-to-analog converter included by Tandy with several
models of the 1000 and 2500. Generally speaking, only Tandy
and some game programmers have written programs for the chip.
The few programs that support the Tandy DAC include DeskMate
Music and Sound, which were bundled with the machine, and a
Windows 3.1 sound driver for the 2500-series, available from
Radio Shack (this driver will also work on the 1000RSX).
This package is intended to supplement, not replace, the many
good sound and music programs out there. There is no point in
trying to redo something that has already been done better than
I could do it. This package, therefore, needs several free-
and shareware programs available separately to be most useful.
Where possible, I make note of other programs that are
available.
Sox, the universal sound sample translator, is an extremely
useful program, so useful that it is a "must have" if you
intend to do anything with sound. Sox can convert most any
sound sample format you are likely to encounter. It can also
perform several effects on the sound file, including adjusting
the sampling rate, mixing channels, high-, low- and bandpass
filtering, adjusting the volume, and echo and vibrato effects.
This program is freeware.
MultiPlayer is a music module player that supports a wide
variety of sound cards; unfortunately, the Tandy sound chip is
not one of them. MultiPlayer can play many module formats,
including MOD, 6CM, 8CM, WOW, STM, S3M, 669, OKT, MED, and P16.
This program requires a 286; module players that don't require
a 386 are scarce. MultiPlayer's usefulness to Tandy owners
lies in the fact that it can play modules to a DAC on a
parallel port and to disk. It can also play to the PC speaker,
but this is not recommended since the sound quality is
extremely poor. With Setdac (described below), you can play
modules in real time on the Tandy DAC, but the quality will be
mediocre because of the low sampling rate you can use. To get
better quality, select "Raw sample file" as the output device,
convert the module into an 8-bit unsigned sample file at up to
22kHz, use Raw2wav (below) to convert the .raw to a .wav, and
use Playwav (also below) to play the .wav. MultiPlayer is
freeware also. NOTE: DO NOT USE MULTIPLAYER V.2.11. THIS
VERSION HAS A BUG IN THE COVOX DRIVER.
ModEdit is a music module editor for 4-channel Amiga module
files. 4-channel .mod's are the least common denominator among
standard music module types; any module player in existence,
for whatever platform, should be able to play them (although
the module format originates with the Amiga, it is now an
industry standard). You can use Setdac to listen to your
modules while you edit them. With Snd2sam, you can use
Sound.pdm to create and edit .mod samples, including looped
samples. ModEdit is shareware; registration is $15.
Conv2snd, by Ken Kudut, is a utility to convert RIFF WAVE and
other sound file formats to .snd so that they can be edited
with Tandy's Sound.pdm sound editor. It comes with another
program, Snd2wav, which converts .snd to .wav, so that sounds
edited with Sound.pdm can be shared with people on non-Tandy
machines. This program is freeware and comes with Turbo Pascal
source. (I did the modifications to v.2.00 of Conv2snd.)
Playsnd, by John Ball, plays Tandy .snd, Creative Labs .voc,
.wav, Amiga .iff, and headerless unsigned PCM files (such as
Mac .snd) on the Tandy DAC or PC speaker. The author also has
a program, Sbplay, to play the same types of sound files (and
several others) on the Soundblaster or PC speaker. Both
programs are free (Sbplay requires free registration).
David Stewart's Sampler package records and plays raw
headerless samples at near 11kHz and features voice activation.
The registered version purportedly provides keyboard activation
(nice because the voice activation seems to have a will of its
own) and allows the sampling rate to be varied. This program
is shareware.
Sean Haynes' Tndsound program records and plays sound files in
its own proprietary format. The unregistered version of this
package does not appear to be crippled. There is a menu-driven
interface. This program offers sound filtering and control
over the playback volume. Overall, I would say that Tndsound
is better than Sampler. One drawback to this program is that
it doesn't know how to compute the sampling rate in Hz from the
DAC divider value, so it's hard to select a standard sampling
rate (you have to specify the rate as a meaningless number).
The default rate is around 9kHz. This program is shareware.
John W. Ratcliffe's IBM Digitized Sound Package contains a TSR,
Tansltl.exe, and a program, Play.exe, to play sounds in a batch
file. This program is commercial ($19.95); it offers sound
compression and a number of other utilities (but recording is
not one of them).
Tandy's own Sound.pdm deserves special mention. Sound allows
you to record, play, and edit sound files, using a graphical
interface (the sound waveform is displayed). The more I see of
Sound.pdm, the more I like it. Sound.pdm runs under Tandy's
proprietary DeskMate interface, which is one of its limita-
tions; on some systems, DeskMate is in ROM and is lost when one
disables the ROM to upgrade the DOS version (DOS 3.3 is also in
ROM). The other limitation is that sound files edited with
Sound.pdm must fit in conventional RAM - but there is still a
great deal of use for the program for short files, such as .mod
samples (see Snd2sam). This program was bundled with several
Tandy models; perhaps they will sell you a copy at Radio Shack
if you tell them you have a 1000TL (or 1000RSX if you have that
or a 2500) and you lost your disk (the standard fee is $5). If
you don't have DeskMate, there is a generic IBM-compatible
version you can buy, also at Radio Shack (it will be a special
order; I don't know the price).
It should be mentioned that if you plan on using the sound
capabilities of the Tandy, you should get a pair of amplified
speakers (~$25-30) at your local Radio Shack and plug them into
the earphone jack on your computer. The built-in speaker does
not produce very good sound.
WARNING: CONNECTING AN AMPLIFIED INPUT (DIRECT LINE FROM
RADIO, ETC.) TO THE MICROPHONE JACK ON YOUR COMPUTER CAN DAMAGE
THE SOUND CIRCUITRY. If you want to connect a stereo, tape
deck, or other device directly to the computer's sound input
via a dubbing cable, you *must* set a jumper inside the
machine. Check your owner's manual before connecting any
amplified input - otherwise you will fry the sound chip and
possibly more.
This version includes eight programs, six of which are (hope-
fully) useful, one (Piano) which is a toy, and one (Testdiv)
which is mainly for programmers. Most of the programs are
described in the following sections; see Tandac.doc for infor-
mation about Testdiv.
Playwav
-------
Playwav plays .wav files on the Tandy sound chip. For sample
files in other formats, use Sox (see above) to convert to .wav.
The RIFF WAVE format, introduced with Windows version 3, is
among the most common sound formats out there. Playwav
requires about 195k of free RAM for its sound buffers.
Arbitrarily large sound files can be played (the file is read
from disk while it's being played).
The WAVE format specification describes many types of sound
files and is a very flexible format. However, only the
simplest type of .wav format is ever actually used, and that is
what this program supports. Specifically, with this program
you can play .wav files in Microsoft PCM format consisting of a
single data block with up to 16 bits per channel in mono or
stereo, at sampling rates up to 65535Hz. This encompasses
99.9% of all .wav files in existence. (One format that is
increasingly common is Microsoft ADPCM - Playwav does not yet
recognize that format.)
To use the program, just type its name at the DOS command line
followed by the name of the .wav file to be played, e.g.:
PLAYWAV FORCE_WI.WAV
On my system, this will play a sound file from Star Wars that
says "Remember, the Force will be with you, always." If the
.wav is not in the current directory, include the drive and/or
path.
Playwav will then play the sound file. You can abort playback
by hitting <control>-C.
There are no command-line options, and Playwav won't display
anything on the screen unless something goes wrong. Here are
the possible error messages:
Tandy DAC not detected.
You get this message if you attempt to run this program on a
computer that does not have a Tandy sound chip. The 3-voice
tone and noise generator included with older 1000-series models
is not sufficient, and you will get this message if you try
Playwav on one of those. The 1000SL's, TL's and RL's and some
later Tandy models have the necessary sound chip.
Must specify input .wav file.
You get this message if you do not specify a .wav file to be
played on the command line.
Open failed on input file.
You get this message if the file you specified does not exist.
There is also a remote possibility that open may fail for
another reason, such as a sharing conflict on a network.
Playwav requires that you specify the extension.
Error reading .wav file.
You get this message if DOS reports an error reading from the
file after it has been opened. You may have a bad spot on your
disk, or the disk structure may be corrupted.
.wav file invalid or unsupported type.
This message indicates that the .wav file you specified does
not have a .wav header that Playwav recognizes. Either the
file you specified is not a .wav file, or the file is corrupt,
or it is one of the rare types of .wav files that Playwav does
not support.
Unsupported sample size or number of channels in .wav file.
You get this message when the .wav header indicates that the
.wav file has more than 16 bits per channel or more than 2
channels. Another possibility is that the .wav is corrupt. If
the .wav is valid, you can use Ppwav to convert it to something
that Playwav can play (see below).
Output underflow - unable to maintain sampling rate.
Copy .wav to hard disk or RAM disk and try again,
convert to 8-bit mono, or convert to reduce sampling
rate.
This message indicates that your computer is unable to generate
samples as fast as they need to be played. Although Playwav is
written in hand-optimized assembler, your hardware may limit
the types of .wav's you can play. Playwav was written and
tested on a 1000TL. On this machine, I have played a 16-bit
stereo 44kHz .wav from the hard drive, but the best that I can
do from a floppy is 8-bit mono 11kHz. The SL is a slower
machine and may not be able to do as well. If you get this
message, you can use Ppwav to convert the .wav so that you can
play it (see below).
Recwav
------
Recwav records .wav files on the Tandy sound chip. The program
requires about 97k of free RAM. Arbitrarily large sound files
can be recorded, subject to disk space limitations (the file is
written to disk while it records). The output file is a RIFF
WAVE file in 8-bit mono Microsoft PCM format. **SEE THE
WARNING ABOVE REGARDING AMPLIFIED INPUT.**
To use the program, type its name, followed by optional
switches, followed by the name of the output file, for example:
RECWAV MINABIRD
RECWAV /S ASOUND.
RECWAV /30000 C:\SOUNDS\SLOWSND
RECWAV /N NOCHECK.WAV
The following options are recognized:
/S means to compute the input sampling rate as for a
1000SL. The SL must be programmed differently from other
machines when recording sounds. Recwav will attempt to detect
an SL if you do not specify either /S or /T on the command
line; this switch overrides the detection mechanism. Note that
Recwav may not detect an SL/2, so this switch may be useful in
that case. By default (if /N is not specified) the sampling
rate will be adjusted by timing the chip, so /S will only save
a little time at startup.
/T means to compute the input sampling rate as for a
1000TL. This is the default for models other than the 1000SL.
As with /S, /T overrides the detection mechanism for an SL. /S
and /T change the rate at which recording is done, /S causing a
faster rate to be used - if /N is also specified. If /N is not
specified, Recwav will adjust the computed rate by timing the
sound chip, as noted above.
/N tells Recwav to skip adjusting the sampling rate. The
Tandy DAC can only record at a discrete set of rates, and by
default Recwav will look for an available rate close to the
specified one (or to the default rate of 11000Hz if you don't
specify a rate). The .wav header will be adjusted to match the
rate chosen.
If /N is specified, on the other hand, Recwav will attempt
to select an available rate close to the one specified, but it
will not adjust the rate or change the .wav header. The
adjustment is much faster now than in the previous version,
taking approximately one second on average (if starting with
the proper estimate for the model involved). Recwav will still
start up a little faster with /N, but sounds will play back
closer to the true pitch if /N is not specified.
/N will mainly be useful in cases where the system timer
has been speeded up from the default rate of 18.2 ticks per
second by some TSR. To do its adjustment, Recwav must take
over the timer tick interrupt; when done, Recwav changes the
rate back to the default rate since there is no way to know if
the timer was speeded up before. Likely culprits here are GW-
Basic and multi-tasking environments such as DesqView; in this
case /N is mandatory.
/nnnn is an optional sampling rate in Hz; for example,
/11025 or /44100. A rate between 875 and 65535 may be
specified. The default rate is 11000.
Higher sampling rates generally imply better sound quality,
at the cost of greater disk space - the rate is equal to the
number of bytes per second of sound that will be written to
your disk. The default rate is adequate for speech. If
recording music, you may want to specify a higher rate.
Standard rates are 5513Hz, 11025Hz, 22050Hz, and 44100Hz, but
you can select any rate in the allowed range.
When selecting a sampling rate, note that your disk must be
fast enough to accept data at the specified rate. This is most
likely to be a problem when recording to a floppy. If your
disk can't keep up, Recwav will abort recording, display a
message (see below), and delete the output file. On a 1000TL
with a reasonably fast hard drive, I can use the full range (up
to about 63kHz), but when recording to a floppy, the available
rate drops to less than 9000Hz.
As note above, Recwav will normally adjust the rate you
specify to match one of the sound chip's available rates.
The output filename is required and can include drive and path
if you want. If you do not specify an extension, it defaults
to .wav; to specify a file without an extension, end its name
with a period.
You might notice a short "hitch" in the sound every few seconds
when playing back a recording. It may help to record to a RAM
disk.
When you run Recwav, it displays the following:
I:\>recwav /8000 a:test
Adjusting sampling rate....
Recording RIFF WAVE file at 8082Hz.
Press a key to begin recording.
If /N was specified, you would see:
I:\>recwav /n /8000 a:test
Sampling rate not adjusted.
Recording RIFF WAVE file at 8000Hz.
Press a key to begin recording.
When ready to begin, press any key. Recwav will then say:
Press a key to stop recording.
Hit a key when you want to stop. This version will stop
immediately (i.e., recording is no longer done in 32kB chunks).
If all went well, the program will display:
Recording complete.
... and Recwav will return you to the DOS prompt.
If things _don't_ go well, one of the following error messages
will be displayed:
This program requires a Tandy DAC chip.
This message will be displayed if Recwav fails to detect the
needed sound chip in your system. The 1000SL, 1000TL, and
several later models of the Tandy 1000 and 2500 have the
necessary chip. The 3-voice tone and noise generator included
with older 1000 models is not sufficient.
Recwav - .wav recorder for Tandy
Syntax:
RECWAV [/S] [/T] [/N] [/nnnn] <filename>
This message is displayed if you invoke Recwav without
parameters. At least one parameter (the output filename) is
required.
You forgot to specify an output file.
This message is displayed if you specify one or more switches,
but omit the filename.
Disk error - recording deleted.
This message is displayed in the event of a file error of some
sort. This indicates that the logical structure of the disk is
corrupt - run Chkdsk. As indicated, Recwav will attempt to
delete the output file in this case, but it probably won't be
completely successful.
Disk full - recording halted.
This message is displayed if a full disk is detected while
recording. The output file is kept in this case. You get a
file as large as will fit on the disk.
Input overflow - unable to maintain sampling rate. Record to a hard disk
or RAM disk, or specify a lower rate. Recording deleted.
This message indicates that your disk drive is unable to accept
data as fast as the sound chip is supplying it. The output
file is deleted. As noted above, you are most likely to get
this message when recording to a floppy.
Note that overflow will not occur if you record less than
64k of sound, so you can record short snippets of sound at a
higher rate than your disk would otherwise allow.
Runtime error 003 at 0000:10B2.
This cryptic message indicates that a critical error (i.e., one
of the things that causes "Abort, Retry, Ignore") has occurred
- such as taking the floppy out of the drive while recording to
it. Recwav intercepts critical errors to some extent, in that
the prompt is not displayed, but you still get this message.
If you see this, a partial file may have been written to the
disk, creating a loose chain in the FAT. After verifying that
your disk is good, run Chkdsk/f to convert the loose chain to a
file, and delete the file. (Maybe some bright programmer can
tell me how to deal with this in Turbo Pascal?)
Finally, the following can occur:
I:\>recwav /n d:test
Sampling rate not adjusted.
Recording RIFF WAVE file at 11000Hz.
Unable to create file "d:test.wav".
On my system, D: is a read-only ROM drive, and no new files can
be created there. You can get this message for a number of
other reasons: attempting to write to a write-protected
floppy, attempting to overwrite an existing read-only file, or
just mistyping (i.e., specifying an invalid filename).
Ppwav
-----
Ppwav (preprocess .wav) performs 3 types of conversions of a
.wav file to reduce its size. All of these conversions can be
done with Sox (see above), but Ppwav is much faster and easier
to use. Ppwav needs about 53k of free RAM for its buffers.
To use Ppwav, type its name followed by the input file name and
the output file name, e.g.:
PPWAV PING1.WAV PG.WAV
On my system, this will start up Ppwav on PING1.WAV, a 16-bit
stereo 44kHz .wav and create a new sound file, PG.WAV. (In
case you're wondering, PING1.WAV is a sonar ping taken from the
movie "Hunt for Red October.")
Ppwav will then display some statistics on the input file, for
example:
Input file: PING1.WAV
2 channels
44100 samples per second (Hz)
16 bits per channel
samples are signed
It will then ask you what conversions you want to do:
Mix to mono? (Y/n)
Convert to 8-bit? (Y/n)
Halve sampling rate? (y/N)
The first two conversions are the default, as indicated by the
uppercase "Y". They will be done unless you enter "n" or "N"
at the prompt. The last conversion will not be done unless you
enter "y" or "Y". The conversion may take a couple minutes.
All of these conversions will reduce the size of the file and
make it easier for Playwav to play it if you got the "Output
underflow" message. (That message is the reason Ppwav exists.)
With the Tandy DAC, mixing to mono and converting to 8-bit do
not affect the sound quality since Playwav has to do that
anyway to play the sound; 8-bit mono sound is all the Tandy
chip supports. Halving the sampling rate will adversely affect
the sound quality, however, and you should only do this as a
last resort. I find that 22kHz is about the minimum for
acceptable music, and 11kHz for speech. Halving the sampling
rate is done by discarding every other sample.
If you haven't noticed, standard sampling rates are 5.5kHz,
11kHz, 22kHz and 44kHz. 44kHz 16-bit stereo is what audio CD's
are recorded at. Both Playwav and Ppwav will handle other
sampling rates, however. Sun .au files are recorded at 8kHz,
and Playwav will play them after Sox converts them to .wav.
Ppwav can also handle some rare .wav types that Playwav does
not: sampling rates greater than 65535Hz, more than 2
channels, and more than 16 bits per channel. At least I think
it will, it's supposed to. I've never seen a .wav like that.
It will not handle all possible .wav's, however (just all that
you are likely to see).
Like Playwav, Ppwav doesn't display anything on the screen
unless something goes wrong. Here are the error messages:
Usage: PPWAV <input file> <output file>
- see docs for details.
You get this message if you don't specify an input file and an
output file on the command line. There is no default for the
output file; you have to specify it.
Error opening input file.
You get this message if the file you specified as the input
file does not exist. As with Playwav, there is a remote
possibility of some other cause, but probably you mistyped.
Unable to create output file.
DOS reported that the output file could not be created.
Probably the root directory is full on the disk you specified
(if you specified the root directory), or the disk is full.
Error reading input .wav file.
DOS reported an error reading the input file. This probably
means that the disk structure is corrupt, and you should run
Chkdsk to find out. Unlike Playwav, Ppwav does not replace the
default critical error handler, so if you have a bad spot on
the disk, you will get the infamous "Abort, Retry, Ignore,
Fail?" message instead of this one.
Error writing output .wav file.
The disk structure is probably corrupt. Ppwav ignores a full
disk; you just get as much of the output file as will fit.
(Playwav will play the fragment, but other players may not.)
Input .wav file invalid or unsupported type.
The input file specified is not a .wav or is corrupt, or it is
one of the rare .wav types that Ppwav does not recognize.
Raw2wav
-------
Raw2wav converts 8-bit unsigned raw sample files to .wav by
attaching a valid .wav header so that Playwav can play them.
This program is intended for use with MultiPlayer (see above).
MultiPlayer can convert music modules when "Raw sample file" is
specified as the output device. Since the .raw files produced
by MultiPlayer are typically several megabytes in size, this
program overwrites the original .raw file in order to save disk
space. Sox can do this conversion, but it is substantially
slower and does not overwrite, so you need double the disk
space of the original file. (Raw2wav can also convert Mac .snd
or other types of headerless sound files.)
Since the original file is overwritten, it will be corrupted if
anything goes wrong. Copy the file first if you're worried
about that.
To use Raw2wav, type its name, optionally followed by the
sampling rate, followed by the name of the .raw file to be
converted, e.g.:
RAW2WAV FUGUE.RAW
or:
RAW2WAV /11000 ENTRTAIN.RAW
The sampling rate defaults to 22000Hz if not specified; this is
the highest sampling rate MultiPlayer supports, and its use is
recommended. Since the .raw file has no header, it is
impossible for a player to know how fast the file is to be
played if you don't specify it. It the examples given,
FUGUE.RAW is the raw sample file produced by MultiPlayer when
playing FUGUE.MOD (Bach's organ fugue in D minor) to the Raw
sample file device at 22kHz, and ENTRTAIN.RAW is the file
produced by MultiPlayer when playing ENTRTAIN.MOD (Scott
Joplin's "The Entertainer") to the Raw sample file at 11kHz.
Raw2wav will ask you to confirm that you want to overwrite the
input file:
The input file will be overwritten. Continue? (Y/n)
As the uppercase "Y" indicates, the default is "yes" if you
just hit return; Raw2wav will go on to convert the file. The
input file will be renamed with a ".wav" extension. If you
enter "n" or "N", the following message will be displayed:
Conversion not done.
and the program will terminate without changing the file.
Normally that will be the extent of the user interaction. If
something goes wrong, one of the following error messages will
be displayed:
Must specify input .raw file.
You get this message if you don't specify an input file.
Sampling rate must be an integer in the range 875-65535.
You get this message if you specify a sampling rate that is not
a number, or if the number you specify is not in the indicated
range. The Tandy sound chip cannot handle sampling rates lower
than 875Hz. Rates higher than 65535Hz are technically
possible, but the programs in this package (except Ppwav) do
not support those rates because I don't want to deal with 32-
bit arithmetic on a 16-bit machine. (None of these programs
contain 80386 instructions, or 80286 instructions for that
matter.) If you actually have a .raw file sampled that high
(where did you get it?) you can use Sox to convert it.
Error opening input file for reading.
The input file specified does not exist, or some other error
occurred (unlikely).
Seek failed on input file.
DOS reported that it was unable to seek on the input file. The
input file must be a file, not a device, since Raw2wav needs to
determine its size for the .wav header. A corrupt disk
structure may also cause this error.
Error opening input file for writing.
DOS reported that the file could not be opened for writing.
This probably means that the file is read-only; use Attrib to
remove the read-only attribute.
Error reading from file.
This probably indicates a corrupt disk structure. As with
Ppwav, the default critical error handler is not replaced, so
if you have a bad spot on the disk you will get "Abort, Retry,
Ignore, Fail?" instead of this.
Error writing to file.
DOS reported an error writing to the file. I don't know how
this can happen. A write-protected disk would cause a critical
error instead.
Disk full.
Since only 44 bytes are added to the file during the
conversion, this error is very unlikely. Nevertheless, there
it is.
Insufficient memory.
Since Raw2wav is structured as a .com file rather than an .exe,
it must check for itself whether it has enough room to work in.
Since Playwav and Ppwav are .exe files, DOS checks whether
there is enough memory available before loading them, so in
their case you would get an error message from DOS, not from
the programs themselves. DOS only guarantees that Raw2wav gets
memory equal to its file size; it needs 32k more and checks
whether it has it.
Snd2sam
-------
Snd2sam converts the .snd files produced by Sound.pdm (see
above) to .mod samples (.sam files) for use with ModEdit (see
above) or other Amiga music module editors. Using Snd2sam, you
can use Tandy's excellent Sound editor program to create and
edit .mod samples, and Music.pdm to test them in a composition,
before converting them to .sam. If you create instrument files
with "sustained" (looped) regions, Snd2sam will preserve the
looping information for you - so you can make your own looped
.mod samples (for the new-format .snd files used on the 2500's,
looping information is not preserved).
Snd2sam can require a lot of memory; it reads the entire .snd
file into RAM. Generally, you should have 350kB or more
available. (Since Sound.pdm requires that .snd files fit into
its memory space, and since DeskMate and Sound.pdm require a
lot more memory than Snd2sam, I don't think this is a major
limitation.)
This program converts a DeskMate Sound.pdm instrument or sound
file to one or more .sam files for use with Amiga .mod editors,
particularly ModEdit v.3.1. The input .snd file must be
uncompressed. For each note in the instrument file, two output
files are created: (1) a .sam file, and (2) a .not (ASCII)
file giving needed information about the .sam file, including
its pitch, large-scale tuning, transposition, and looping
parameters. Since the .sam file is a headerless format, the
user is required to enter the information from the .not file
manually when using the sample in a .mod editor.
The syntax is:
SND2SAM <.snd file> [<directory>]
The input .snd filename is required and may include drive and
path. If no extension is specified, it defaults to .snd; a
file without an extension can by used by ending the name with a
period.
The second parameter, which is optional, is the directory where
the output .sam and .not files will be placed. If not
specified, it defaults to the current directory.
The output filenames are generated from the input .snd
filename. For the first note, the filename of the .snd file
(without drive, path, or extension) is taken, and extensions of
.sam and .not are attached. For the second and subsequent
notes, a digit 2-9 or letter A-G is appended to the filename,
overwriting the last character of the filename if necessary.
For example, if the following is entered (where piano.snd is an
instrument file with 3 notes defined):
snd2sam a:piano
The following files will be created in the current directory:
piano.sam
piano.not
piano2.sam
piano2.not
piano3.sam
piano3.not
For a note in an instrument file with pitch and sustain set,
the .not file will take the following format. In this example,
clarinet.snd has at least one note defined, and note 1 is C3 in
Sound.pdm (middle C, or C2 in .mod pitch).
Data for sample file clarinet.sam
Actual pitch at C2: G1 finetune +1
Tuning for ModEdit v.3.1:
Set tuning to: G2
Transpose up 1 octave(s).
Tuning for other editors:
Transpose up 5 semitone(s).
Sample is looped.
Repeat start: 3828 (1914 words)
Repeat length: 1356 (678 words)
The .not file begins with the name of the sample file it
describes. The next line gives the actual pitch of the note
(in .mod pitch) if played back at period 428. The pitch given
here need not be a valid .mod pitch; it can have an octave
number from -1 to 4. The finetune is somewhat of a mathemati-
cal artifact; theoretically, given what I know of the Tandy
DAC, the .mod format, and sound frequencies, that is what it
should be. On my TL, however, I find that a finetune of 0 is
correct. You will have to experiment to determine the right
finetune for your system, but the finetune you use should be
the same for every .snd file you convert. Likely values to
specify are -1 and 0.
The pitch is based on the value you specify in Sound.pdm. It
has to be adjusted for use in a .mod file. In Sound.pdm, all
instrument files are recorded at 11kHz, and note pitches are
based on that rate. To make different notes, Music.pdm plays
the note samples back at higher or lower rates, and it bases
the playback rate on the pitch of the note at 11kHz (i.e., the
pitch at which you recorded the note). This method of playing
different notes, called "frequency shifting," is the same
method used on the Amiga (and PC .mod players). On the Amiga,
there is no way to specify the implied note; all notes
(samples) are assumed to play at middle C (C2) when played back
at 8363Hz. If you have samples that play at a different pitch
at that speed, it is your responsibility to transpose the notes
(as if you were scoring for a G or B-flat instrument in an
orchestra) before entering them into the module. The transpos-
ition information displayed tells you how many half-steps up or
down you must transpose.
ModEdit v.3.1 is an exception to the rule. This program allows
you to set a "large-scale" tuning value for a sample so that
notes you enter for that sample are automatically transposed.
This feature is unique to ModEdit, as far as I know; it is not
part of the .mod format. If you are using ModEdit, you can use
the large-scale tuning attribute to select a base pitch in
octave 2, and you will then only have to transpose (if at all)
in octaves.
The next few lines in the .not file describe how to set the
large-scale tuning in ModEdit so that the pitch will be true (a
C will be a C, a D-flat a D-flat, etc.) and so that the range
will be as large as possible (a large-scale tuning in octave 2
is always selected). Depending on the .snd file, it may be
necessary to transpose the sample's notes one or more octaves
in either direction. In this example, the notes will sound one
octave lower than they are written when the tuning is set as
indicated, so if working from a musical score one must
transpose them up one octave. Note that you can set the large-
scale tuning to G1 (the pitch given as the "actual pitch") and
not have to transpose at all - but then the range of the
instrument will be limited (see the ModEdit documentation on
sample attributes).
Other .mod editors do not offer large-scale tuning; a note
played at period 428 (8363Hz) is always displayed as C2. In
this case, the sample's notes will sound 5 semitones lower than
they are written, so if working from a musical score one must
transpose them up 5 semitones.
The last part is the sample's looping information. In the
example, the first note of clarinet.snd has the sustain region
set, and this region will be used as the repeat region for the
sample. The repeat start and length are given in bytes (since
ModEdit requires bytes) and in words (which is what the .mod
format requires, and what other .mod editors may use).
A word about "sustain" and looping is in order. In computer
music, a note is said to consist of three parts: the "attack,"
the swelling of tone at the beginning of the note; the
"sustain," the period of constant tone in the middle of the
note; and the "decay," the fading of tone at the end of the
note. DeskMate Sound and Music provide for all three; the
"attack" and "decay" are implicitly set when you set the
"sustain" region. Tandy's Music.pdm is way ahead of Amiga's
Protracker in this and other respects; it was ahead of its
time. A long note is held by repeatedly playing (looping over)
the samples in the sustain section. Amiga .mod files provide
for a beginning section (an "attack") and a looped section (a
"sustain"), but there is no "decay."
Accordingly, if you convert a note with sustain set, the part
of the note after the sustain will be discarded, since on an
Amiga it won't be played anyway (or it will be played at the
wrong time, when the note starts). The sustain section in the
.snd note will become the looped section in the .mod sample.
Also, since the Tandy allows you to set the sustain interval to
the byte, while the Amiga only lets you set the looping to the
word, the beginning and end of the sustain interval will be
rounded off to a multiple of two. (The file size is also
rounded off, for the same reason.)
If you convert one of the new-format .snd files used on the
2500-series, the looping information will not be preserved. I
don't know where the sustain information is kept in the new
.snd header (my information about new-format .snd's is
generally much sketchier than for the old format). All .not
files for new-format .snd's will indicate that the "Sample is
not looped."
The .sam file is a headerless format; it contains no informa-
tion about large-scale tuning, finetune or looping. You have
to use the .not file to enter these values manually in your
.mod editor.
For a sound file, or for a note in an instrument file with no
pitch or sustain set, the .not file will take the following
format:
Data for sample file meep.sam
No pitch set
Sample is not looped.
If you didn't set the pitch in the .snd file, Snd2wav can't
help you with tuning, so that information is omitted.
The .sam file will consist of a zero word followed by 8-bit
signed PCM samples. (The zero word is another Amiga artifact.)
Known bug: Snd2sam cannot use a read-only .snd file. This is
a bug in Turbo Pascal's runtime library; it is impossible to
open a read-only binary file (one of the great advantages of
using high-level languages, I suppose ...). The bug applies
only to files made read-only with the Attrib +r command, not to
files on write-protected floppies. The only way to fix this is
to rewrite TP's file handling routines in assembler; I have not
done so. Use Attrib -r to unprotect the .snd file (Snd2sam
does not modify the .snd file).
When you run Snd2sam, you will see something like this:
I:\>snd2sam piano test
Snd2sam - DeskMate .snd to Amiga .mod sample conversion program
Reading note information ...
Reading sample data ...
Writing to directory "test":
Writing file piano.sam ...
Writing file piano.not ...
Writing file piano2.sam ...
Writing file piano2.not ...
Writing file piano3.sam ...
Writing file piano3.not ...
Done.
It will take only a few seconds on a hard drive. As always,
things can go wrong, and Snd2sam will provide a message if they
do. Here's one:
Syntax:
SND2SAM <.snd file> [<output directory>]
You get this message if you invoke Snd2sam without parameters.
The input .snd file name is required.
Unable to open file:
qqq.snd
File qqq.snd does not exist. You also get this message if you
try to convert a read-only .snd file (see bug note above).
File "modnotes." is not an .snd file.
The specified input file is not a DeskMate .snd file or is
corrupt. The .snd extension is used by many different systems
for many different types of files. You should not assume
anything about a file with an .snd extension.
Unexpected end-of-file reading .snd header of file:
qqq.snd
The .snd file is corrupt or truncated, or the specified input
file is not an .snd file and is less than 16 bytes in length.
File "h:piano.snd" is compressed.
Use Sound.pdm to uncompress before converting.
Snd2sam can only convert uncompressed .snd files. To convert a
file for which you get this message, load the file into
Sound.pdm and select the Compression option. Select "No
compression," then Save.
Error reading input file - halting.
This means what it says; probably the disk structure is
corrupt.
Insufficient memory.
There is not enough memory to read the .snd file in. You are
most likely to get this if you run Snd2sam when shelled out of
something.
Note too long for .mod sample - note skipped.
DeskMate Sound and Music set no limits on how long a note
sample can be (except that the sample must fit in memory).
Amiga .mod samples are limited to a maximum of 128k, and this
message indicates that the sample for the note is longer than
that. Note that many PC .mod players will not deal correctly
with samples longer than 64k, although Snd2sam will convert
them. If you get this message, you will have to edit the note
with Sound.pdm to make it shorter. In general, if you need to
play long notes in your .mod, it is better to create a looped
sample - you avoid problems with the PC's 64k limit, and your
.mod will take less RAM and disk space. One note is skipped if
you see this message, but if there are other notes in the
instrument file they will be converted.
You cannot create looped samples from new-format .snd
files, unfortunately.
Note contains no sound data - note skipped.
This message indicates that the file contains a note that was
created but never recorded into. It is purely informational;
the rest of the notes will be converted.
Error writing output file - halting.
As above, this means what it says. Run Chkdsk to see if your
disk is messed up.
Disk full - halting.
Self-explanatory. If part of the .snd has been converted, the
.snd and .not files for that part will be on the disk.
Error creating file "piano.sam" in directory
"d:" - halting.
The output directory specified is not writeable (in this case,
D: is a ROM disk) or is the root directory and is full.
Invalid sample directory:
qqq
The directory you specified for the output files does not
exist. Note that the second command-line parameter is a
directory, not a filename.
There are a couple other possible error messages. They
probably indicate that the .snd file is corrupt.
Setdac
------
Setdac sets up the Tandy DAC to operate in byte-by-byte mode,
as if it were a homemade DAC attached to a parallel port. By
itself, this program doesn't do anything useful. It is
intended to be run before another program that supports
homemade DAC's (many do). The best way to use Setdac is to
create a batch file for each program you want to use it with,
for example:
I:\>copy con mt.bat
setdac
multip
^Z
1 File(s) copied
With Setdac.com and Multip.exe in my path, I can now type "MT"
to run MultiPlayer. Assuming MultiPlayer is configured for the
Tandy chip (see below), I can now use the DAC as an output
device with it.
It should be noted that writing sound data byte-by-byte to the
DAC is not the best way to use the chip. Doing it this way
puts a severe strain on the processor, limiting the sampling
rate and consequently the sound quality you can achieve. It is
preferable (and easier) to use the Tandy DAC in DMA mode with
the BIOS interface. Setdac is just a hack to enable programs
that otherwise do not support the Tandy chip to use it, albeit
not the way it was meant to be used.
Setdac is not a TSR; it just programs the DAC registers to put
the chip in byte-by-byte mode. Once it is in this mode, any
program can use it as if it were a homemade or Covox DAC on a
parallel port, that is, by writing bytes to its port address.
Setdac will display the port address in hexadecimal when it is
run; write it down so you have it when you configure your
application for the Tandy chip. Note that the port will not be
a standard LPT port address, so if your application limits you
to standard addresses, you're out of luck.
Setdac takes no command-line arguments. If it detects a Tandy
DAC in your system, it will display its port address:
Tandy DAC at port 00C5h.
If a Tandy DAC is not found, the following will be displayed:
Tandy DAC not detected.
Setdac exits without doing anything in this case.
Setdac is only for sound output. It is possible to set the DAC
to perform sound input byte-by-byte, if anyone comes up with a
reason to do so, but the register programming would be
different (i.e., you can't set the DAC to do both input and
output at the same time).
Each application that you use Setdac with will have to be
configured for the Tandy chip. How you do this will vary with
the application involved. Generally, you will want to select
"DAC on LPT1:" or "Covox DAC" or such like for the output
device and set the "I/O port address" or "base address" to the
port number displayed by Setdac. As with a homemade DAC, you
will also need to set the "sampling rate" or "output frequency"
to something your system will support. For the best sound
quality, set the rate as high as possible, but remember that if
you set it too high your computer may lock up or crash. There
is no firm guide on what you should set the sampling rate to;
it depends on the application and the speed of your machine.
Start with the lowest sampling rate your application allows and
increase it by increments until the program locks up the
machine, then set the rate to the highest value that works
without locking up. I have a Tandy 1000TL with an 8MHz 80286.
The highest rate I can use with MultiPlayer is 6000Hz; with
ModEdit, the highest rate is 8000Hz.
Configure MultiPlayer v.2.01 for the Tandy DAC as follows.
NOTE: DO NOT USE MULTIPLAYER V.2.11. THIS VERSION HAS A BUG
IN THE COVOX DAC DRIVER. Type <alt>-F to bring up the "File"
menu and select "CLASSIC" for the Playing mode and "Covox Mono"
for the Output device. Type <esc> to exit the "File" menu and
<alt>-S to bring up the "Setup" menu. Set the Frequency Mix
Rate to "5000", which is the lowest rate MultiPlayer supports;
you will adjust it later. Optionally, you may want to set Save
Memory Space for Mods to "NO" (this will speed up playback a
little) and increase the Initial Volume (the default is pretty
soft). Leave the other stuff alone and hit <esc> to exit the
"Setup" menu. Type <alt>-D to bring up the "Devices" menu and
set the Covox Left I/O Address to the value displayed by
Setdac. Leave the other stuff alone and hit <esc> twice to
exit MultiPlayer; your settings will be saved. Now run Setdac
and restart MultiPlayer. Hit F3 and play a module. The
Frequency Rate is displayed in the upper right corner. Hit the
<up arrow> key to increase the rate. Eventually, one of three
things will happen. Either (1) MultiPlayer will knock the rate
back down; (2) the music will get horribly staticky; or (3)
your system will lock up. You are looking for the highest
_sustainable_ rate. Some parts of a module are easier to play
than others, and MultiPlayer may be able to achieve higher
rates on the "easy" parts, but you want to find the highest
rate that works for both "easy" and "hard" parts of the module.
This is trial and error. When you find the rate you want, go
back into the "Setup" menu and set the Frequency Mix Rate to
the highest rate you can use. Hit <esc> to exit MultiPlayer,
and make a batch file to run Setdac each time you run
MultiPlayer, as described above.
Configure ModEdit v.3.01 for the Tandy DAC as follows. Type C
to bring up the "Configure" menu, then type P to set the
Playback device. Select "B: D/A converter on LPT1" and hit
<enter>. Next type A to set Address of LPT ports. Set the
LPT1: address to the value displayed by Setdac and hit <enter>
three times. Type M to set the Mixing speed. Type "5000" at
the prompt and hit <enter>. This is the lowest mixing speed
ModEdit supports; as above, you will increase the speed later.
Now type S to Save configuration and hit <esc> to exit the
"Configure" menu. Type F to bring up the "File" menu and X to
Exit ModEdit. Run Setdac and restart ModEdit. Use the "File"
menu to load a module (ModEdit comes with one) and use the
"Play" menu to play it. Now it's trial and error to find the
right rate. Unlike MultiPlayer, ModEdit does not fail
gracefully (i.e., knocking the rate back down) if you set it
too high. It just locks up your machine - so when you find a
rate that works, use the "Configure" menu to set the Mixing
speed and Save configuration, then go on looking for a better
rate, keeping your finger poised over the ol' red button.
ModEdit is designed to let you go on editing the module while
it plays, so hit some keys while the module is playing to see
whether your machine will keep up.
It is a hassle to find the right sampling rate for an
application, but you only have to do it once. If you get
frustrated, take a break and walk in the woods (or corfields or
desert, whatever you have). :-)
Piano
-----
Piano is a silly little program to play the SN76496-equivalent
circuitry on the IBM PC-Jr or Tandy 1000 or 2500 like a piano.
Unlike the other programs, this one does not require an SL/TL
or later model; this one uses the 3-voice chip. The following
keys are used:
Key Note
caps lock not used
left shift A2
A A#2
Z B2
S not used
X C3
D C#3
C D3
F D#3
V E3
G not used
B F3
H F#3
N G3
J G#3
M A3
K A#3
, B3
L not used
. C4
; C#4
/ D4
' D#4
right shift E4
enter not used
` not used
tab F4
1 F#4
Q G4
2 G#4
W A4
3 A#4
E B4
4 not used
R C5
5 C#5
T D5
6 D#5
Y E5
7 not used
U F5
8 F#5
I G5
9 G#5
O A5
0 A#5
P B5
- not used
[ C6
= C#6
] D6
backspace D#6
\ E6
<esc> exits the program. In accordance with the sound chip's
capabilities, up to 3 notes can be played at a time. Notes
given are American Standard Pitch, Equal Tempered Scale, or as
close as I can get; C4 (period) is middle C. High notes are
not as close to the true frequency as low ones.
This program always plays notes at the maximum volume; there is
no volume control.
When the program starts, it displays the keyboard layout:
-- Tandy Piano --
1 2 3 5 6 8 9 0 = backsp
F#4 G#4 A#4 C#5 D#5 F#5 G#5 A#5 C#6 D#6
tab Q W E R T Y U I O P [ ] \
F4 G4 A4 B4 C5 D5 E5 F5 G5 A5 B5 C6 D6 E6
A D F H J K ; '
A#2 C#3 D#3 F#3 G#3 A#3 C#4 D#4
shift Z X C V B N M , . / shift
A2 B2 C3 D3 E3 F3 G3 A3 B3 C4 D4 E4
Period is middle C. Hit <escape> to halt the program.
This program was written on a Tandy 1000TL with a 101-key
keyboard. If you have another keyboard, the key for the top
note will be in the wrong place. On the 83-key keyboard, the
top note is the \ key on the bottom row next to the left shift.
On the 84-key keyboard, the top note is the \ key on the top
row between = and backspace. On the old Tandy keyboard (1000TX
and prior), the top note is the left arrow key.
This program requires a PCjr or Tandy 1000 (or later Tandy)
with the Texas Instruments SN76496 3-voice sound chip or
equivalent circuitry. The program will check to see if you
have the chip. If not, it will display the following:
This program requires a PC-Jr or Tandy 1000 or 2500 with a 3-voice tone
generator. It will not run on your machine.
Work in Progress
----------------
The following would also be nice:
Recwav and Playwav should support Microsoft ADPCM
compression to save disk space. I'm still looking for
information on the format.
Support for the Tandy DAC in ModEdit, without having to use
Setdac and going through all the rigamarole above (I have
corresponded with the author of the module playing routines
in ModEdit about this).
A program to convert .sng to .mod. Since .sng files only
have 3 channels, it is impossible to convert .mod to .sng
without loss.
A program to play music modules using the DMA capabilities
of the Tandy sound chip, rather than converting them to
.wav or using byte-by-byte transfers. This should be able
to play 4-, 6- or 8-channel .mod's, to begin with. (In
progress - still. Actually, I haven't started it yet, but
I will soon. :-)
There should be some information on programming the Tandy
joystick.